using System.Collections.Generic;
using UnityEngine;

public class ProbConfig
{
	private List<ProbInfo> _probInfos = new List<ProbInfo>();

	private int _totalProb;

	public List<ProbInfo> probInfos => _probInfos;

	public ProbConfig(string filePath)
	{
		_probInfos = Utils.LoadXML<ProbInfo>(filePath);
		for (int i = 0; i < _probInfos.Count; i++)
		{
			ProbInfo probInfo = _probInfos[i];
			_totalProb += probInfo.prob;
		}
	}

	public ProbInfo GetItem()
	{
		int num = 0;
		int num2 = Random.Range(num, _totalProb);
		for (int i = 0; i < _probInfos.Count; i++)
		{
			ProbInfo probInfo = _probInfos[i];
			int num3 = num + probInfo.prob;
			if (num2 >= num && num2 < num3)
			{
				return probInfo;
			}
			num = num3;
		}
		return null;
	}
}
